﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using public_dbOpt;

namespace prjEMR22_154
{
    public partial class MR_contrl_exditDE : Form
    {
        dbOPT dataOpt = new dbOPT();
        public static string Word;
        public static bool medicine_check;
        public static bool inspect_check;
        public static bool Medrecrd_check;

        public MR_contrl_exditDE()
        {
            InitializeComponent();
        }

        private void MR_contrl_exditDE_Load(object sender, EventArgs e)
        {
            medicine_check = false;
            inspect_check = false;
            Medrecrd_check = false;

            if (Word == "MR_contrl_exdit")
            {
                label1.Text = "确定删除该病历？";
            }
            else if (Word == "Medicine_exdit")
            {
                label1.Text = "确定删除该药品？";
            }
            else if (Word == "Inspect_exdit")
            {
                label1.Text = "确定删除该项目？";
            } 

        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (Word == "MR_contrl_exdit")
            {
                string strhsp = PatientInfo_inquire_checked.strHspID;
                string sql = String.Format("DELETE FROM medrecordinfo WHERE HspID = '{0}' and 病历序号 = '{1}';", strhsp, MR_contrl_exdit.strxuhao);
                dataOpt.OperateData(sql);
                Medrecrd_check = true;
            }
            else if (Word=="Medicine_exdit")
            {
                string strmedicineID = Medicine_exdit.strMedicineID;
                string sql = String.Format("DELETE FROM medicineinfo WHERE MedicineID = '{0}';", strmedicineID);
                dataOpt.OperateData(sql);

                medicine_check = true;
            }
            else if (Word=="Inspect_exdit")
            {
                string strInspectID = Inspect_exdit.strInspectID;
                string sql = String.Format("DELETE FROM inspectinfo WHERE InspectID = '{0}';", strInspectID);
                dataOpt.OperateData(sql);

                inspect_check = true;
            }
            MessageBox.Show("删除成功。");
            this.Close();
            
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            this.Close();

            medicine_check = false;
            inspect_check = false;
        }



    }
}
